//Tuesday, November 17 2009
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

vector<string> table; //make this private or in the class will cost more time.

class TheBasketballDivTwo
{
public:
	int find(vector <string> t)
	{
		table = t;
		N = table.size();
		ret = INT_MAX;
		recursive(0, 0);
		return ret;
	}
	void recursive( int row, int col)
	{
		if(row == N)
		{
			ret = min(ret, calc());
			return;
		}
		if(col == N)
			recursive(row+1, 0);
		else
		{
			if(table[row][col]!='?')
				recursive(row, col+1);
			else
			{
				table[row][col] = 'W';
				recursive( row, col+1);
				table[row][col] = 'L';
				recursive(row, col+1);
				table[row][col] = '?';
			}
		}
	}
	int calc()
	{
		vector<int> v(N,0);
		for(int i=0; i<N; i++)
			for(int j=0; j<N; j++)
				v[i] += (table[i][j]=='W') + (table[j][i]=='L');
		sort(v.begin(), v.end());
		return min(ret, v[N-1]);
	}
	int N;
	int ret;
};